import React, { Component } from 'react';

import axios from 'axios';
export default class Son2 extends Component {

    render() {
        return (
            <div>我是son2组件</div>
        )
    };
    // 以类成员属性形式设置controller
    controller = new AbortController();

    componentDidMount() {
        // 网络请求
        axios.get('https://reactapi.iynn.cn/captcha/api/math', {
            signal: this.controller.signal
        }).then(res2 => {
            console.log('res2', res2);
        }).catch(err => {
            console.log(err);
        })
    };
    componentWillUnmount() {
        // 取消网路请求
        this.controller.abort()
    }
}
